home *** CD-ROM | disk | FTP | other *** search
- Path: hops.cs.jhu.edu!lasher
- From: lasher@hops.cs.jhu.edu (John E. Davis)
- Newsgroups: comp.lang.c
- Subject: help with strcmp
- Date: 1 Apr 1996 21:39:32 GMT
- Organization: JHU computer science
- Message-ID: <4jpiek$lp6@blaze.cs.jhu.edu>
- NNTP-Posting-Host: hops.cs.jhu.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- For some reason when I try to compare the strings in the following
- snippet I consistently get a core dump (running on a UNIX machine running
- Solaris). Could anyone point out what may be going wrong? I have run it
- through the debugger and that was no help at all for me. here is the
- code snippet:
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- void setup(FILE *);
-
- void main(int argc, char *argv[])
- {
- char buf[20], data[40], *buff, *arg, *fp;
- FILE *handle, *dest;
- int n;
-
- handle = fopen(argv[1], "r");
- if(dest = fopen( "dbuild.out", "w")) setup(dest);
-
- while(!feof(handle)) {
- n = 0;
- fp = fgets(data, 40, handle);
- if ( strcasecmp(fp, "<action>\n") == 0) /* the coredump is here */
- parseAction(handle, dest);
- else if ( strcasecmp(fp, "<control>\n") == 0)
- parseControl(handle, dest);
- else if ( strcasecmp(fp, "<general>\n") == 0)
- parseGeneral(handle, dest);
- printf("%s", data);
- }
- fclose(dest);
-
- }
-
-
- --
- John Davis
- lasher@hops.cs.jhu.edu
- http://hops.cs.jhu.edu/~lasher
-
- UNIX is a very user-friendly operating system
- it's just picky about who it's friends with.
-